<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>葡萄资源评价鉴定系统</title>
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>

</head>
<body>
<div style="margin-top: 200px;" align="center">
    <div class="easyui-panel" title="葡萄资源评价鉴定系统" style="width:100%;max-width:400px;padding:30px 60px ; align: center;">
        <form id="from">
            <div class="form-group" style="margin-bottom: 20px">
                <input class="easyui-textbox" type="text" id="username" name="username" style="width:100%"
                       data-options="label:'账号:',required:true" placeholder="请输入用户名" class="input-material">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" type="password" id="password" name="password" style="width:100%"
                       data-options="label:'密码:',required:true" placeholder="请输入密码" class="input-material">
            </div>
        </form>
        <div style="text-align:center;padding:5px 0">
            <button id="login" class="easyui-linkbutton" style="width:80px" onclick="Login()">登录</button>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">注册</a>
        </div>

    </div>
    <script type="text/javascript">
        function Login() {
            var username = $('#username').val();
            var password = $('#password').val();
            var data = {"username":  username ,"password":password };
            //将实体类转换为json
            var datas = JSON.stringify(data);
            alert(data);
            if (username == "") {
                alert("用户名不能为空");
                return;
            }
            if (password == "") {
                alert("密码不能为空");
                return;
            }
            $.ajax({
                url: "users/login",
                contentType: "application/json;charset=UTF-8",
                data: datas,
                dataType: "json",
                type: "post",
                success: function (data) {
                    alert(data.msg);
                    //alert("访问到这了" + datas);
                    if (data.msg == 1) {
                        alert("欢迎登录");
                        window.location.href = "home.html";
                    } else {
                        alert("用户名或密码错误！");
                        window.location.href = "login.html";
                    }
                }
            });
        }
        function clearForm() {
            location.href = "resign.html";
        }
    </script>
</div>
</body>

</html>
